//
//  XMLLanguagesParser.m
//  LanguagesTeach
//
//  Created by Niel Santos on 12/15/12.
//  Copyright 2012 __MyCompanyName__. All rights reserved.
//

#import "XMLLanguagesParser.h"
#import "Language.h"

@implementation XMLLanguagesParser

@synthesize languages;

- (void)parser:(NSXMLParser *)parser 
		didStartElement:(NSString *)elementName
		namespaceURI:(NSString *)namespaceURI
		qualifiedName:(NSString *)qualifiedName
		attributes:(NSDictionary *)attributeDict{
	//Variables declaration
	Language *language = nil;
	
	if([elementName isEqualToString:@"languages"]) {
		//Treat languages
		languages = [[NSMutableArray alloc] init];
	}else if([elementName isEqualToString:@"language"]) {
		language = [[Language alloc] init];
		language.title = [attributeDict objectForKey:@"title"];
		language.prefix = [attributeDict objectForKey:@"prefix"];
		[languages addObject: language];
		[language release];
		//Treat language
	}
}

- (void)dealloc {
	[languages release];
    [super dealloc];
}

@end
